package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ysd.common.Result;
import com.ysd.lis.entity.WkEmployeeJobHistory;
import com.ysd.lis.entity.WkEmployeeProDirection;
import com.ysd.lis.mapper.WkEmployeeProDirectionMapper;
import com.ysd.lis.service.WkEmployeeProDirectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 员工档案-专业方向表 服务实现类
 * </p>
 *
 * @author LiuQi
 * @since 2024-02-23
 */
@Service
public class WkEmployeeProDirectionServiceImpl extends ServiceImpl<WkEmployeeProDirectionMapper, WkEmployeeProDirection> implements WkEmployeeProDirectionService {

    @Autowired
    WkEmployeeProDirectionMapper wkEmployeeProDirectionMapper;

    @Override
    public Result getEmployeeProDirectionList(String wkEmployeeId) {
        LambdaQueryWrapper<WkEmployeeProDirection> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WkEmployeeProDirection::getDelFlag, 0)
                .eq(WkEmployeeProDirection::getWkEmpId, wkEmployeeId);
        List<WkEmployeeProDirection> wkEmployees = wkEmployeeProDirectionMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功！", wkEmployees);
    }

    @Override
    public Result addEmployeeProDirection(WkEmployeeProDirection wkEmployeeProDirection) {
        boolean save = this.save(wkEmployeeProDirection);
        if (save) {
            return Result.succ(1, "添加成功", null);
        } else {
            return Result.fail("添加失败");
        }
    }

    @Override
    public Result updateEmployeeProDirection(WkEmployeeProDirection wkEmployeeProDirection) {
        boolean save = this.updateById(wkEmployeeProDirection);
        if (save) {
            return Result.succ(1, "编辑成功", null);
        } else {
            return Result.fail("编辑失败");
        }
    }

    @Override
    public Result deleteEmployeeProDirection(WkEmployeeProDirection wkEmployeeProDirection) {
        boolean b = this.removeById(wkEmployeeProDirection.getId());
        if (b) {
            return Result.succ(1, "删除成功", null);
        } else {
            return Result.fail("删除失败");
        }
    }
}
